import json


class Utils:
    @classmethod
    def load_json2dict(cls, json_file: str) -> None:
        """ 将json文件转换为字典

        Args:
            json_file (str): 文件路径
        """
        with open(json_file, 'r') as f:
            return json.load(f)

    @classmethod
    def save_dict2json(cls, json_file: str, data: dict) -> json:
        """ 将字典保存为json文件

        Args:
            json_file (str): 文件路径
            data (dict): dict 数据

        Returns:
            json: _description_
        """
        with open(json_file, 'w', encoding="utf-8") as f:
            # ensure_ascii=False，不转码
            json.dump(data, f, ensure_ascii=False)
            print(f"File {json_file.split('/')[-1]} saved")
